package com.example.christina.controller;

import com.example.christina.enity.Shopcart;
import com.example.christina.service.ShopcartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "shopcart")
public class ShopcartController {

    @Autowired
    private ShopcartService shopcartService;

    @PostMapping(path = "addShopcart")
    public void addShopcart(@RequestBody Shopcart shopcart){
        shopcartService.addShopcart(shopcart);
    }

    @DeleteMapping(path = "deleteShopcart")
    public void deleteShopcart(@RequestBody Shopcart shopcart){
        shopcartService.deleteShopcart(shopcart);
    }

    @GetMapping(path = "getShopcart")
    //查看购物车
    public List<?> getShopcart(String username){
        return shopcartService.getShopcart(username);
    }

}
